/* Copyright (C) 2010 Luca Piccinelli
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/* 
 * File:   utility_data_structures.h
 * Author: picci
 *
 * Created on 1 agosto 2010, 12.27
 */

#ifndef UTILITY_DATA_STRUCTURES_H
#define	UTILITY_DATA_STRUCTURES_H

#include <string>
#include <ostream>
#include <typeinfo>

#include "prj_definitions.h"
#include "pdl.h"
#include "exceptions/gestface_exceptions.h"

namespace NAMESPACE{

// ****** Key ******************************************************************
class Key{
public:
    const static std::string KEY_SEPARATOR;

protected:
    std::string ns;
    std::string key_name;

public:
    virtual ~Key();
    Key();
    Key(const Key& k);
    Key& operator=(const Key& k);

    std::string get_key() const;
    
    void set_key(const std::string& key_str);
    void set_key(const std::string& _ns, const std::string& _key_name);

    virtual bool operator==(const Key& k) const;
    virtual bool operator!=(const Key& k) const;
    virtual bool operator< (const Key& k) const;
};
// -----------------------------------------------------------------------------

// ****** IOKey ****************************************************************
class IOKey : public Key{
private:
    std::string type;
    SerializablePDLElement* pdlElement;

public:
    virtual ~IOKey();
    IOKey();
    IOKey(const IOKey& k);
    IOKey& operator=(const IOKey& k);

    std::string getType() const;
    void set_key_and_type(const std::string& key_type_str);
    IOKey& setType(const std::string& _type);
    IOKey& setAcceptedValues(const std::string& accepted);
    IOKey& setAcceptedValues(const SerializablePDLElement& accepted);
    const SerializablePDLElement& getAcceptedValues() throw(gestface_exception);

    bool operator==(const Key& k) const;
    bool operator!=(const Key& k) const;
    bool operator< (const Key& k) const;
};
// -----------------------------------------------------------------------------

std::ostream& operator<<(std::ostream os, const Key& k);

REGISTER_PARSE_TYPE(IOKey)
REGISTER_PARSE_TYPE(IOKey*)
}

#endif	/* UTILITY_DATA_STRUCTURES_H */

